import EventEmitterUtils from "@page/common/utils/EventEmitterUtils";
import Uts from "@module/Uts";

export default class SoldNumber extends React.Component {
    constructor() {
        super();
        let loginSuppId=Uts.getCookie('suppId');
        let routerSuppId=$state.params&&$state.params.suppId;
        this.state = {
            isSuppSelf:loginSuppId==routerSuppId? true:false
        };
    }

    onClick() {
        if (global.hasLogin) {
            EventEmitterUtils.emit("scollToProductComments", null);
        }
    }

    isSuppSelf(){
        let flag=false;
        if($state.params&&$state.params.suppId){
            flag=$state.params.suppId==Uts.getCookie('suppId')
        }
        return flag;
    }



    render() {
        const { product, totalComments } = this.props;
        const { saleAmount } = product;
        const {isSuppSelf}=this.state;
        return (
            <div className={"detail-top-sold-nums"}>
                <div className={"detail-top-sold-num1"}>
                    <p className={"detail-top-sold-num-p"}>月销量</p>
                    {
                        (!global.hasLogin&&!isSuppSelf)?
                        <p className={"zen_m-l-10 zen_m-t-5"}>
                            {"***"}
                        </p>
                            :
                        <p className={"detail-top-sold-num-p1"}>
                            {saleAmount||0}
                        </p>
                    }
                </div>
                <div
                    onClick={this.onClick}
                    className={
                        global.hasLogin
                            ? "detail-top-sold-num3"
                            : "detail-top-sold-num2"
                    }
                >
                    <p className={"detail-top-sold-num-p"}>
                        累计评价
                    </p>
                    {
                        (!global.hasLogin&&!isSuppSelf)?
                            <p className={"zen_m-l-10 zen_m-t-5 "}>
                                {"***"}
                            </p>
                            :
                            <p className={"detail-top-sold-num-p1"}>
                                {totalComments||0}
                            </p>

                    }
                </div>
            </div>
        );
    }
}
